package mvc.views.mediators
{
	import globals.Global;
	
	import mvc.Notifications;
	import mvc.views.frames.FrameMain;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	public class MediatorMainFrame extends Mediator
	{
		public static const NAME:String = "MediatorMainFrame";
		
		private var _frame:FrameMain=null;

		public function MediatorMainFrame(mediatorName:String=null, viewComponent:Object=null)
		{
			super(mediatorName, viewComponent);
		}
		
		public function get frame():FrameMain
		{
			return _frame;
		}
		
		override public function listNotificationInterests():Array
		{
			// TODO Auto Generated method stub
			return [
				Notifications.MEDIATOR_SELECT_MAIN,
				Notifications.MEDIATOR_UPDATE_MAIN_DATA
			];
		}
		
		override public function handleNotification(notification:INotification):void
		{
			// TODO Auto Generated method stub
			super.handleNotification(notification);
			
			switch(notification.getName())
			{
				case Notifications.MEDIATOR_SELECT_MAIN:
					if(!_frame)
					{
						_frame = new FrameMain();
					}
					Global.uiLayer.addChild(_frame);
					_frame.changeMain({type:0});
					_frame.show();
					break;
				case Notifications.MEDIATOR_UPDATE_MAIN_DATA:
					_frame.update(notification.getBody());
					break;
			}
		}
	}
}